package Vista;

import Entidades.Historica;
import Entidades.PantallaAplicacion;
import Entidades.Proveedor;
import Logica.FactoryVistas;
import Logica.LogicaAplicacion;
import Logica.LogicaProveedorPregunta;
import java.awt.Color;
import java.util.ArrayList;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import javax.swing.JOptionPane;

/**
 *
 * @author Puma
 */
public class RegistroLineasTelefonicas extends javax.swing.JFrame implements Runnable{

    private int cantv = 0, intel = 0, movistar = 0, digitel = 0, netuno = 0, otros = 0;
    private int minutos = 0, segundos = 0, horas = 0;
    private Boolean inicio = true;
    private Thread t;
    private Pattern patron = Pattern.compile("[A-Z,a-z,&%$#@!()*^]");
    private Matcher matcher = null;
    private ArrayList servicios = null;
    private ArrayList<Proveedor> proveedores = new ArrayList<Proveedor>();
    private ArrayList<Historica> inserts = null;
    private Historica h = null;
    private int numPreg = 1;
    private LogicaProveedorPregunta logicaProveedorPregunta = new LogicaProveedorPregunta();
    private int posicionActual;
    private Boolean fuePrevia = false;

    /** Creates new form RegistroLineasTelefonicas */
    public RegistroLineasTelefonicas(int minutos, int segundos, int horas,ArrayList servicios) {
        initComponents();
        this.minutos = minutos;
        this.segundos = segundos;
        this.horas = horas;
        this.servicios = servicios;
        this.inserts = new ArrayList<Historica>();
        iniciarReloj();
    }

    public RegistroLineasTelefonicas() {
        initComponents();
    }

    public RegistroLineasTelefonicas(int minutos, int segundos, int horas,ArrayList servicios,int posicionActual){
        initComponents();
        this.minutos = minutos;
        this.segundos = segundos;
        this.horas = horas;
        this.servicios = servicios;
        this.inserts = new ArrayList<Historica>();
        this.setPosicionActual(posicionActual);
        iniciarReloj();
        agregarPantalla();
        System.out.println("Posicion actual: "+posicionActual);
    }

    private void agregarPantalla(){
        LogicaAplicacion.agregarPantallaLista(new PantallaAplicacion(this, numPreg));
    }
    
    public Boolean getFuePrevia() {
        return fuePrevia;
    }

    public void setFuePrevia(Boolean fuePrevia) {
        this.fuePrevia = fuePrevia;
    }

    private void iniciarReloj(){
        t = new Thread(this);
        t.start();
    }
    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jLayeredPane1 = new javax.swing.JLayeredPane();
        jLTimer = new javax.swing.JLabel();
        jLSponsor = new javax.swing.JLabel();
        jLLogo = new javax.swing.JLabel();
        jLTitulo = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();
        jLabel7 = new javax.swing.JLabel();
        jLabel9 = new javax.swing.JLabel();
        jLabel8 = new javax.swing.JLabel();
        jTMovistar = new javax.swing.JTextField();
        jTNetUno = new javax.swing.JTextField();
        jTCantv = new javax.swing.JTextField();
        jTDigitel = new javax.swing.JTextField();
        jTInter = new javax.swing.JTextField();
        jTOtros = new javax.swing.JTextField();
        jLErrorSuma = new javax.swing.JLabel();
        jLErrorSuma1 = new javax.swing.JLabel();
        jLabel1 = new javax.swing.JLabel();
        jLSumaServicios = new javax.swing.JLabel();
        jBAceptar = new javax.swing.JButton();
        jScrollPane1 = new javax.swing.JScrollPane();
        jTextArea1 = new javax.swing.JTextArea();
        jLabel11 = new javax.swing.JLabel();
        jBPrev = new javax.swing.JButton();
        jTOtrosProveedores = new javax.swing.JTextField();
        jLabel10 = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        jLTimer.setText("jLabel11");
        jLTimer.setBounds(740, 10, 90, 14);
        jLayeredPane1.add(jLTimer, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jLSponsor.setText("Desarrollado para Datinvest C.A");
        jLSponsor.setBounds(110, 40, 220, 14);
        jLayeredPane1.add(jLSponsor, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jLLogo.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Vista/Imagenes/DatinvestLogo.png"))); // NOI18N
        jLLogo.setBounds(10, 10, 80, 80);
        jLayeredPane1.add(jLLogo, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jLTitulo.setFont(new java.awt.Font("Tahoma", 3, 14));
        jLTitulo.setText(".:: Instrumento de emprendedores - Planilla de servicios de voz::. ");
        jLTitulo.setBounds(90, 20, 550, 14);
        jLayeredPane1.add(jLTitulo, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jLabel2.setText("Tomando en cuenta sus sucursales y sedes ¿Cuántas Líneas Telefónicas Comercilaes fijas tienen en la Empresa / Institución actualmente?");
        jLabel2.setBounds(10, 100, 820, 14);
        jLayeredPane1.add(jLabel2, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jLabel3.setText("Cantidad");
        jLabel3.setBounds(330, 140, 90, 20);
        jLayeredPane1.add(jLabel3, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jLabel4.setText("Movistar / Telefónica:");
        jLabel4.setBounds(60, 180, 130, 20);
        jLayeredPane1.add(jLabel4, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jLabel5.setText("Digitel:");
        jLabel5.setBounds(60, 200, 80, 20);
        jLayeredPane1.add(jLabel5, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jLabel6.setText("Veninfotel / Net Uno:");
        jLabel6.setBounds(60, 220, 120, 20);
        jLayeredPane1.add(jLabel6, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jLabel7.setText("Inter:");
        jLabel7.setBounds(60, 240, 70, 20);
        jLayeredPane1.add(jLabel7, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jLabel9.setText("CANTV:");
        jLabel9.setBounds(60, 160, 70, 20);
        jLayeredPane1.add(jLabel9, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jLabel8.setText("Otros:");
        jLabel8.setBounds(60, 260, 70, 20);
        jLayeredPane1.add(jLabel8, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jTMovistar.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusLost(java.awt.event.FocusEvent evt) {
                jTMovistarFocusLost(evt);
            }
        });
        jTMovistar.setBounds(340, 180, 40, 20);
        jLayeredPane1.add(jTMovistar, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jTNetUno.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusLost(java.awt.event.FocusEvent evt) {
                jTNetUnoFocusLost(evt);
            }
        });
        jTNetUno.setBounds(340, 220, 40, 20);
        jLayeredPane1.add(jTNetUno, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jTCantv.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusLost(java.awt.event.FocusEvent evt) {
                jTCantvFocusLost(evt);
            }
        });
        jTCantv.setBounds(340, 160, 40, 20);
        jLayeredPane1.add(jTCantv, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jTDigitel.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusLost(java.awt.event.FocusEvent evt) {
                jTDigitelFocusLost(evt);
            }
        });
        jTDigitel.setBounds(340, 200, 40, 20);
        jLayeredPane1.add(jTDigitel, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jTInter.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusLost(java.awt.event.FocusEvent evt) {
                jTInterFocusLost(evt);
            }
        });
        jTInter.setBounds(340, 240, 40, 20);
        jLayeredPane1.add(jTInter, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jTOtros.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusLost(java.awt.event.FocusEvent evt) {
                jTOtrosFocusLost(evt);
            }
        });
        jTOtros.setBounds(340, 260, 40, 20);
        jLayeredPane1.add(jTOtros, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jLErrorSuma.setFont(new java.awt.Font("Tahoma", 1, 11));
        jLErrorSuma.setForeground(new java.awt.Color(255, 0, 51));
        jLErrorSuma.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Vista/Imagenes/lineaDivisoria.png"))); // NOI18N
        jLErrorSuma.setText("jLabel11");
        jLErrorSuma.setBounds(30, 310, 800, 14);
        jLayeredPane1.add(jLErrorSuma, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jLErrorSuma1.setFont(new java.awt.Font("Tahoma", 1, 11));
        jLErrorSuma1.setForeground(new java.awt.Color(255, 0, 51));
        jLErrorSuma1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Vista/Imagenes/lineaDivisoria.png"))); // NOI18N
        jLErrorSuma1.setText("jLabel11");
        jLErrorSuma1.setBounds(30, 120, 800, 14);
        jLayeredPane1.add(jLErrorSuma1, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jLabel1.setText("Total:");
        jLabel1.setBounds(290, 290, 40, 14);
        jLayeredPane1.add(jLabel1, javax.swing.JLayeredPane.DEFAULT_LAYER);
        jLSumaServicios.setBounds(340, 280, 40, 30);
        jLayeredPane1.add(jLSumaServicios, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jBAceptar.setText("Aceptar");
        jBAceptar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jBAceptarActionPerformed(evt);
            }
        });
        jBAceptar.setBounds(740, 330, 90, 23);
        jLayeredPane1.add(jBAceptar, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jTextArea1.setColumns(20);
        jTextArea1.setFont(new java.awt.Font("Tahoma", 0, 12));
        jTextArea1.setRows(5);
        jScrollPane1.setViewportView(jTextArea1);

        jScrollPane1.setBounds(410, 160, 420, 130);
        jLayeredPane1.add(jScrollPane1, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jLabel11.setText("Comentarios adicionales del entrevistado");
        jLabel11.setBounds(410, 140, 370, 14);
        jLayeredPane1.add(jLabel11, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jBPrev.setText("< Prev");
        jBPrev.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jBPrevActionPerformed(evt);
            }
        });
        jBPrev.setBounds(660, 330, 70, 23);
        jLayeredPane1.add(jBPrev, javax.swing.JLayeredPane.DEFAULT_LAYER);
        jTOtrosProveedores.setBounds(100, 260, 190, 20);
        jLayeredPane1.add(jTOtrosProveedores, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jLabel10.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Vista/Imagenes/fondoBlanco.png"))); // NOI18N
        jLabel10.setText("jLabel10");
        jLabel10.setBounds(0, 0, 850, 360);
        jLayeredPane1.add(jLabel10, javax.swing.JLayeredPane.DEFAULT_LAYER);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jLayeredPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 851, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jLayeredPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 359, Short.MAX_VALUE)
        );

        java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
        setBounds((screenSize.width-867)/2, (screenSize.height-397)/2, 867, 397);
    }// </editor-fold>//GEN-END:initComponents

    private void jBAceptarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBAceptarActionPerformed

        System.out.println("-- Obteniendo cuentas de proveedores");
        //Insertando proveedores segun el orden
        
        if (!this.jTCantv.getText().isEmpty()){
            proveedores.add(new Proveedor("CANTV",Integer.parseInt(jTCantv.getText())));
        }
        else
            proveedores.add(new Proveedor("CANTV",0));
        
        if (!this.jTMovistar.getText().isEmpty()){
            proveedores.add(new Proveedor("MOVISTAR / TELEFONICA",Integer.parseInt(jTMovistar.getText())));
        }
        else
            proveedores.add(new Proveedor("MOVISTAR / TELEFONICA",0));
        
        if (!this.jTDigitel.getText().isEmpty()){
            proveedores.add(new Proveedor("DIGITEL",Integer.parseInt(jTDigitel.getText())));
        }
        else
            proveedores.add(new Proveedor("DIGITEL",0));
        
         if (!this.jTNetUno.getText().isEmpty()){
            proveedores.add(new Proveedor("VENINFOTEL / NET UNO",Integer.parseInt(jTNetUno.getText())));
        }
        else
            proveedores.add(new Proveedor("VENINFOTEL / NET UNO",0));
        
        if (!this.jTInter.getText().isEmpty()){
            proveedores.add(new Proveedor("INTER",Integer.parseInt(jTInter.getText())));
        }
        else
            proveedores.add(new Proveedor("INTER",0));
        
        if (!this.jTOtros.getText().isEmpty()){
            proveedores.add(new Proveedor("OTRO",Integer.parseInt(jTOtros.getText())));
        }
        else
            proveedores.add(new Proveedor("OTRO",0));

        //System.out.println(jLSumaServicios.getText());
        
        jLSumaServicios.setText(String.valueOf(sumarLineas()));
        LogicaAplicacion.setP3(Integer.parseInt(jLSumaServicios.getText()));
        
        for (Proveedor p: proveedores){
           
            h = new Historica();
            
            h.setPp_id(logicaProveedorPregunta.
                       obtenerIdServicioSeleccionado
                       (p.getProv_nombre(),numPreg));
            
            h.setCantidad(p.getCantidad());
            
            this.getInserts().add(h);
        }
        
       // new LogicaHistorico().insertarDataLineasTelefonicasyCpa(inserts);
        LogicaAplicacion.actualizarPantalla(numPreg, this);
        
       if (!this.fuePrevia){
            System.out.println("Agregar la pantalla a la lista, y ya!");            
            this.servicios.remove(0);
            FactoryVistas.obtenerSiguientePregunta(servicios, minutos, segundos, horas,this.getPosicionActual()+1).setVisible(true);
            this.setVisible(false);
        }
       else {            
            System.out.println("No voy a remover de la lista de servicios, ni insertare en la lista... pero actualizare");            
            LogicaAplicacion.mostrarPantallaSiguiente(this.getPosicionActual()+1);
            this.setVisible(false);
       }                        
    }//GEN-LAST:event_jBAceptarActionPerformed

    private int sumarLineas(){
     
        int suma = 0;
     
        if (!jTCantv.getText().equals(""))
           suma = suma + Integer.parseInt(jTCantv.getText());
    
        if (!jTMovistar.getText().equals(""))
           suma = suma + Integer.parseInt(jTMovistar.getText());
        
        if (!jTDigitel.getText().equals(""))
           suma = suma + Integer.parseInt(jTDigitel.getText());
        
        if (!jTInter.getText().equals(""))
           suma = suma + Integer.parseInt(jTInter.getText());
        
        if (!jTNetUno.getText().equals(""))
           suma = suma + Integer.parseInt(jTNetUno.getText());
        
        if (!jTOtros.getText().equals(""))
           suma = suma + Integer.parseInt(jTOtros.getText());
        
        return suma;
    }

    private void jTOtrosFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_jTOtrosFocusLost
        try {
            if (!this.jTOtros.getText().isEmpty()){
                if (!contieneLetras(this.jTOtros.getText())){
                    otros = Integer.parseInt(this.jTOtros.getText());
                    suma();
                }
            }
        } catch (NumberFormatException ex){
            JOptionPane.showMessageDialog(null,"Los datos "
                    + "introducidos deben ser numéricos" + ex.getMessage(),"Error",
                    JOptionPane.ERROR_MESSAGE);
        }
}//GEN-LAST:event_jTOtrosFocusLost

    private void jTInterFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_jTInterFocusLost
        try {
            if (!this.jTInter.getText().isEmpty()){
                if (!contieneLetras(this.jTInter.getText())){
                    intel = Integer.parseInt(this.jTInter.getText());
                    suma();
                }
            }
        } catch (NumberFormatException ex){
            JOptionPane.showMessageDialog(null,"Los datos "
                    + "introducidos deben ser numéricos" + ex.getMessage(),"Error",
                    JOptionPane.ERROR_MESSAGE);
        }
}//GEN-LAST:event_jTInterFocusLost

    private void jTNetUnoFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_jTNetUnoFocusLost
        try {
            if (!this.jTNetUno.getText().isEmpty()){
                if (!contieneLetras(this.jTNetUno.getText())){
                    netuno = Integer.parseInt(this.jTNetUno.getText());
                    suma();
                }
            }
        } catch (NumberFormatException ex){
            JOptionPane.showMessageDialog(null,"Los datos "
                    + "introducidos deben ser numéricos" + ex.getMessage(),"Error",
                    JOptionPane.ERROR_MESSAGE);
        }
}//GEN-LAST:event_jTNetUnoFocusLost

    private void jTDigitelFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_jTDigitelFocusLost
        try {
            if (!this.jTDigitel.getText().isEmpty()){
                if (!contieneLetras(this.jTDigitel.getText())){
                    digitel = Integer.parseInt(this.jTDigitel.getText());
                    suma();
                }
            }
        } catch (NumberFormatException ex){
            JOptionPane.showMessageDialog(null,"Los datos "
                    + "introducidos deben ser numéricos" + ex.getMessage(),"Error",
                    JOptionPane.ERROR_MESSAGE);
        }
}//GEN-LAST:event_jTDigitelFocusLost

    private void jTMovistarFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_jTMovistarFocusLost
        try {
            if (!this.jTMovistar.getText().isEmpty()){
                if (!contieneLetras(this.jTMovistar.getText())){
                    movistar = Integer.parseInt(this.jTMovistar.getText());
                    suma();
                }
            }
        } catch (NumberFormatException ex){
            JOptionPane.showMessageDialog(null,"Los datos "
                    + "introducidos deben ser numéricos" + ex.getMessage(),"Error",
                    JOptionPane.ERROR_MESSAGE);
        }
}//GEN-LAST:event_jTMovistarFocusLost

    private void jTCantvFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_jTCantvFocusLost
        try {
            if (!this.jTCantv.getText().isEmpty()){
                if (!contieneLetras(this.jTCantv.getText())){
                    cantv = Integer.parseInt(this.jTCantv.getText());
                    suma();
                }                
            }
        } catch (NumberFormatException ex){
            JOptionPane.showMessageDialog(null,"Los datos "
                    + "introducidos deben ser numéricos" + ex.getMessage(),"Error",
                    JOptionPane.ERROR_MESSAGE);
        }
}//GEN-LAST:event_jTCantvFocusLost

    private void jBPrevActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBPrevActionPerformed
        try {
            this.setVisible(false);
            LogicaAplicacion.mostrarPantallaRegreso(this.getPosicionActual() - 1);
        } catch (Exception ex) {
            this.setVisible(true);
            JOptionPane.showMessageDialog(null,ex.getMessage());
        } 
    }//GEN-LAST:event_jBPrevActionPerformed

    private Boolean contieneLetras(String cadena){        
        matcher = patron.matcher(cadena);
        
            if (matcher.find())
                return true;
            else return false;        
    }

    public void hacerVisible(Boolean visible, int posicionActual){
        this.setPosicionActual(posicionActual);
        this.proveedores = new ArrayList<Proveedor>();
        this.setFuePrevia(true);
        this.setInserts(new ArrayList<Historica>());
        this.setVisible(visible);
        System.out.println("Posicion actual: "+posicionActual);
    }

     public void hacerVisibleDespuesSiguiente(Boolean visible, int posicionActual){
        this.proveedores = new ArrayList<Proveedor>();
        this.setPosicionActual(posicionActual);
        this.setInserts(new ArrayList<Historica>());
        this.setVisible(visible);
        System.out.println("Posicion actual: "+posicionActual);
    }
     
    private void suma(){
        jLSumaServicios.setText(""+(cantv+intel+movistar+digitel+netuno+otros));
    }

    public ArrayList<Historica> getInserts() {
        return inserts;
    }

    public void setInserts(ArrayList<Historica> inserts) {
        this.inserts = inserts;
    }

    public int getPosicionActual() {
        return posicionActual;
    }

    private void setPosicionActual(int posicionActual) {
        this.posicionActual = posicionActual;
    }
    
    /**
    * @param args the command line arguments
    */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new RegistroLineasTelefonicas().setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jBAceptar;
    private javax.swing.JButton jBPrev;
    private javax.swing.JLabel jLErrorSuma;
    private javax.swing.JLabel jLErrorSuma1;
    private javax.swing.JLabel jLLogo;
    private javax.swing.JLabel jLSponsor;
    private javax.swing.JLabel jLSumaServicios;
    private javax.swing.JLabel jLTimer;
    private javax.swing.JLabel jLTitulo;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JLayeredPane jLayeredPane1;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JTextField jTCantv;
    private javax.swing.JTextField jTDigitel;
    private javax.swing.JTextField jTInter;
    private javax.swing.JTextField jTMovistar;
    private javax.swing.JTextField jTNetUno;
    private javax.swing.JTextField jTOtros;
    private javax.swing.JTextField jTOtrosProveedores;
    private javax.swing.JTextArea jTextArea1;
    // End of variables declaration//GEN-END:variables

       public void run() {
        try {
            while (inicio){

                if(segundos != 59) {
                   segundos++;
                }else{
                    if(minutos != 59){
                        segundos = 0;
                        minutos++;
                    }else{
                            horas++;
                            minutos = 0;
                            segundos = 0;
                    }
                }

                if (minutos >= 10)
                    jLTimer.setForeground(Color.red);

                    jLTimer.setText(horas+":"+minutos+":"+segundos);

                Thread.sleep(999);
            }

        } catch (InterruptedException ex) {
            System.out.println("Error en el sleep de aplicacion = " +ex.getMessage());
        }
    }

}
